/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.onlineresortreservation.helper;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import org.onlineresortreservation.connection.Dbcon;

/**
 *
 * @author Admin
 */
public class AuthenticateAdmin {
    
    
    Dbcon dbcon = new Dbcon();
    Connection con;
    Statement stmt;
    PreparedStatement psmt;
    ResultSet rs, rs1;
    String sql;

    public int authenticate(String adminemailid, String password) {
        int auth=0;
        String gotpassword="";
        try {
            String sql = "Select AdminPassword from admin where EmailId=?";
            con = dbcon.open();
            psmt = con.prepareStatement(sql);
            psmt.setString(1, adminemailid);

            rs = psmt.executeQuery();
            
            if(rs.next())
            {
                gotpassword=rs.getString("AdminPassword");
            }
            
            if(gotpassword.equals(password))
            {
                auth=1;
                
                
            }else
            {
                auth=0;
            }
            
            System.out.println(auth);
            
        }catch (Exception exc) {
            String excmsg = exc.getMessage();
            System.out.println(excmsg);
            
        }
       return auth;

    }
    
    
}
